bitkeeper revision 1.1159.220.3 (41e670c37jmaTxUns3KlvsbVRCg-UA)
authormafetter@fleming.research <mafetter@fleming.research>
Thu, 13 Jan 2005 12:59:47 +0000 (12:59 +0000)
committermafetter@fleming.research <mafetter@fleming.research>
Thu, 13 Jan 2005 12:59:47 +0000 (12:59 +0000)
The getdomaininfo hypercall now listens to the exec_domain parameter
that was already passed to it, and performs some basic sanity checking.

Added exec_domain (aka vcpu) parameters to xc_domain_getfullinfo()
and xc_domain_get_cpu_usage().

tools/libxc/xc.h
tools/libxc/xc_domain.c
tools/libxc/xc_linux_build.c
tools/libxc/xc_linux_restore.c
tools/libxc/xc_linux_save.c
tools/libxc/xc_plan9_build.c
tools/libxc/xc_private.c
tools/libxc/xc_vmx_build.c
xen/common/dom0_ops.c

index 3c4d03cfc3b2a7dfc71941b285c2a868ece19b73..f8276297a12d7628fd9656fd227c8b58eef83205 100644 (file)
@@ -62,13 +62,15 @@ int xc_domain_getinfo(int xc_handle,
                       xc_dominfo_t *info);
 int xc_domain_getfullinfo(int xc_handle,
                           u32 domid,
+                          u32 vcpu,
                           xc_domaininfo_t *info,
                           full_execution_context_t *ctxt);
 int xc_domain_setcpuweight(int xc_handle,
                            u32 domid,
                            float weight);
 long long xc_domain_get_cpu_usage(int xc_handle,
-                                  domid_t domid);
+                                  domid_t domid,
+                                  int vcpu);
 
 
 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
index 1d34b3e4053e6b7a240b178df71ccf97af44deff..7104ea1a48bd9c9a82e258fb9e05f8b8559b07bc 100644 (file)
@@ -88,6 +88,7 @@ int xc_domain_getinfo(int xc_handle,
     {
         op.cmd = DOM0_GETDOMAININFO;
         op.u.getdomaininfo.domain = (domid_t)next_domid;
+        op.u.getdomaininfo.exec_domain = 0; // FIX ME?!?
         op.u.getdomaininfo.ctxt = NULL; /* no exec context info, thanks. */
         if ( do_dom0_op(xc_handle, &op) < 0 )
             break;
@@ -121,6 +122,7 @@ int xc_domain_getinfo(int xc_handle,
 
 int xc_domain_getfullinfo(int xc_handle,
                           u32 domid,
+                          u32 vcpu,
                           xc_domaininfo_t *info,
                           full_execution_context_t *ctxt)
 {
@@ -129,6 +131,7 @@ int xc_domain_getfullinfo(int xc_handle,
 
     op.cmd = DOM0_GETDOMAININFO;
     op.u.getdomaininfo.domain = (domid_t)domid;
+    op.u.getdomaininfo.exec_domain = (u16)vcpu;
     op.u.getdomaininfo.ctxt = ctxt;
 
     rc = do_dom0_op(xc_handle, &op);
index 0932f5cacfef602fcb30a82486795638fb751d84..e155c1feb46a63bb660b2dca37e4026bc05dfc9d 100644 (file)
@@ -370,6 +370,7 @@ int xc_linux_build(int xc_handle,
 
     op.cmd = DOM0_GETDOMAININFO;
     op.u.getdomaininfo.domain = (domid_t)domid;
+    op.u.getdomaininfo.exec_domain = 0;
     op.u.getdomaininfo.ctxt = ctxt;
     if ( (do_dom0_op(xc_handle, &op) < 0) || 
          ((u16)op.u.getdomaininfo.domain != domid) )
index d7ed2d677659b06ff241bfe087dd1f6bd94d0da8..8909878f8141c337ba5482416373812c97eeba99 100644 (file)
@@ -177,6 +177,7 @@ int xc_linux_restore(int xc_handle, XcIOContext *ioctxt)
     /* Get the domain's shared-info frame. */
     op.cmd = DOM0_GETDOMAININFO;
     op.u.getdomaininfo.domain = (domid_t)dom;
+    op.u.getdomaininfo.exec_domain = 0;
     op.u.getdomaininfo.ctxt = NULL;
     if ( do_dom0_op(xc_handle, &op) < 0 )
     {
index 95224467366e714ca25966e5dbde5c941d1b631d..9d07efe15832dfd3b9e0db07d0f1c9f84041a7b3 100644 (file)
@@ -232,8 +232,8 @@ static int print_stats( int xc_handle, u32 domid,
 
     gettimeofday(&wall_now, NULL);
 
-    d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0 )/1000;
-    d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid )/1000;
+    d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0, /* FIXME */ 0 )/1000;
+    d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid, /* FIXME */ 0 )/1000;
 
     if ( (d0_cpu_now == -1) || (d1_cpu_now == -1) ) 
         printf("ARRHHH!!\n");
@@ -331,7 +331,7 @@ int suspend_and_state(int xc_handle, XcIOContext *ioctxt,
 
 retry:
 
-    if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, info, ctxt) )
+    if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, /* FIXME */ 0, info, ctxt) )
     {
        xcio_error(ioctxt, "Could not get full domain info");
        return -1;
@@ -444,7 +444,7 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
         return 1;
     }
 
-    if ( xc_domain_getfullinfo( xc_handle, domid, &info, &ctxt) )
+    if ( xc_domain_getfullinfo( xc_handle, domid, /* FIXME */ 0, &info, &ctxt) )
     {
         xcio_error(ioctxt, "Could not get full domain info");
         goto out;
index 819969c57dbaa2bb88faf669ca2a004646a4c6e0..f3198097161732cf4f8ecc8c84ed50f11b99609b 100755 (executable)
@@ -467,6 +467,7 @@ xc_plan9_build(int xc_handle,
 
        op.cmd = DOM0_GETDOMAININFO;
        op.u.getdomaininfo.domain = (domid_t) domid;
+        op.u.getdomaininfo.exec_domain = 0;
        op.u.getdomaininfo.ctxt = ctxt;
        if ((do_dom0_op(xc_handle, &op) < 0) ||
            ((u32) op.u.getdomaininfo.domain != domid)) {
index cbf42cc68fbba922458d1d73ac80afc2eb53902d..65aa1085e0b8a77e7b68103e1be5e89211e1de95 100644 (file)
@@ -160,12 +160,13 @@ int finish_mmu_updates(int xc_handle, mmu_t *mmu)
 }
 
 
-long long  xc_domain_get_cpu_usage( int xc_handle, domid_t domid )
+long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid, int vcpu )
 {
     dom0_op_t op;
 
     op.cmd = DOM0_GETDOMAININFO;
     op.u.getdomaininfo.domain = (domid_t)domid;
+    op.u.getdomaininfo.exec_domain = (u16)vcpu;
     op.u.getdomaininfo.ctxt = NULL;
     if ( (do_dom0_op(xc_handle, &op) < 0) || 
          ((u16)op.u.getdomaininfo.domain != domid) )
@@ -248,6 +249,7 @@ long xc_get_tot_pages(int xc_handle, u32 domid)
     dom0_op_t op;
     op.cmd = DOM0_GETDOMAININFO;
     op.u.getdomaininfo.domain = (domid_t)domid;
+    op.u.getdomaininfo.exec_domain = 0;
     op.u.getdomaininfo.ctxt = NULL;
     return (do_dom0_op(xc_handle, &op) < 0) ? 
         -1 : op.u.getdomaininfo.tot_pages;
index 58f31cd79725a9000dd6b2b367eda8c25e73fcbb..85de2a3f97f93234f3a51662f081627cfd9c8fa0 100644 (file)
@@ -430,6 +430,7 @@ int xc_vmx_build(int xc_handle,
 
     op.cmd = DOM0_GETDOMAININFO;
     op.u.getdomaininfo.domain = (domid_t)domid;
+    op.u.getdomaininfo.exec_domain = 0;
     op.u.getdomaininfo.ctxt = ctxt;
     if ( (do_dom0_op(xc_handle, &op) < 0) || 
          ((u16)op.u.getdomaininfo.domain != domid) )
index f23bbfd14e2dfd88cc902d0f3aa744dfa6479d7c..b52576f8579b747877de1bf7c7a65d4c60d0dda6 100644 (file)
@@ -354,7 +354,14 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 
         op->u.getdomaininfo.domain = d->id;
 
-        ed = d->exec_domain[0]; // op->u.getdomaininfo.exec_domain];
+        if ( (op->u.getdomaininfo.exec_domain >= MAX_VIRT_CPUS) ||
+             !d->exec_domain[op->u.getdomaininfo.exec_domain] )
+        {
+            ret = -EINVAL;
+            break;
+        }
+        
+        ed = d->exec_domain[op->u.getdomaininfo.exec_domain];
 
         op->u.getdomaininfo.flags =
             (test_bit( DF_DYING,      &d->d_flags)  ? DOMFLAGS_DYING    : 0) |